package cn.com.lyj6851.modules.activity.service.mapper;

import cn.com.lyj6851.common.mapper.CoreMapper;
import cn.com.lyj6851.modules.activity.domain.YdyStoreCombination;
import cn.com.lyj6851.modules.activity.vo.YdyStoreCombinationQueryVo;
import cn.com.lyj6851.modules.product.vo.YdyStoreProductQueryVo;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface YdyStoreCombinationMapper extends CoreMapper<YdyStoreCombination> {

    @Select("SELECT c.id,c.effective_time as effectiveTime,c.info,c.image,c.people,c.price, s.sales as sales," +
            "c.title,c.unit_name as unitName,s.price as productPrice FROM yx_store_combination c " +
            "INNER JOIN yx_store_product s ON s.id=c.product_id " +
            " WHERE c.is_show = 1 AND c.is_del = 0 AND c.start_time < now() " +
            " AND c.stop_time > now() ORDER BY c.sort desc,c.id desc")
    List<YdyStoreCombinationQueryVo> getCombList(Page page);

    //IPage<YdyStoreCombination> selectPage(IPage<YdyStoreCombination> page, @Param("ew") Wrapper<YdyStoreCombination> queryWrapper);

    @Select("SELECT c.id,c.effective_time as effectiveTime,c.image,c.people,c.price,c.browse," +
            "c.description,c.image,c.images,c.info," +
            "c.product_id as productId,c.sales,c.start_time as startTime" +
            ",c.stock,c.stop_time stopTime," +
            "c.title,c.unit_name as unitName,s.price as productPrice FROM yx_store_combination c " +
            "INNER JOIN yx_store_product s ON s.id=c.product_id " +
            " WHERE c.is_show = 1 AND c.is_del = 0 AND c.id = #{id} ")
    YdyStoreCombinationQueryVo getCombDetail(Long id);

    @Select("SELECT c.id,c.image,c.price,c.title as storeName,c.is_show as isShow,c.cost," +
            "c.sales,c.stock,c.is_del as isDel" +
            " FROM yx_store_combination c " +
            " WHERE c.id = #{id} and c.is_del = 0 ")
    YdyStoreProductQueryVo combinatiionInfo(Long id);
}
